<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<body>
<!--添加老人健康信息页面_程辉-->
<div id="app">
    <el-page-header
            style="background-color: #0096dc;color: white;
                    line-height: 60px"
            @back="goBack" content="添加老人健康信息">
    </el-page-header>
    <el-card style="width: 800px;height: 800px;margin: 0 auto">
        <el-form label-width="80px">
            <el-form-item label="老人姓名">
                <el-input v-model="older.name" type="text"></el-input>
            </el-form-item>
            <el-form-item label="联系方式">
                <el-input v-model="older.phoneNum" type="text"></el-input>
            </el-form-item>
            <el-form-item label="老人性别">
                <el-input v-model="older.gender" type="text"></el-input>
            </el-form-item>
            <el-form-item label="老人年龄">
                <el-input v-model="older.age" type="text"></el-input>
            </el-form-item>
            <el-form-item label="老人家属">
                 <el-select placeholder="请选择" v-model="older.userId">
                     <el-option v-for="user in arr"
                                :label="user.username" :value="user.id"></el-option>
                 </el-select>
            </el-form-item>
            <el-form-item label="老人身高">
                <el-input v-model="older.height" type="text"></el-input>
            </el-form-item>
            <el-form-item label="老人体重">
                <el-input v-model="older.weight" type="text"></el-input>
            </el-form-item>
            <el-form-item label="老人血压">
                <el-input v-model="older.bp" type="text"></el-input>
            </el-form-item>
            <el-form-item label="老人血糖">
                <el-input v-model="older.bg" type="text"></el-input>
            </el-form-item>
            <el-form-item label="老人血脂">
                <el-input v-model="older.bl" type="text"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="success" @click="insert()">添加老人信息</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<!--引入axios和vue框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                arr:[],
                older:{
                    name:"",
                    phoneNum:"",
                    gender:"",
                    age:"",
                    userId:"",
                    height:"",
                    weight:"",
                    bp:"",
                    bg:"",
                    bl:""
                }
            }
        },
        created:function(){
            //请求所有用户信息_程辉
            axios.get("/selectUser").then(function (response) {
                v.user = response.data;
            })
        },
        methods:{
            goBack(){
                //返回上一页面
                history.back();
            },
            insert(){
                //添加老人健康信息_程辉
                axios.post("/older/insert",v.older).then(function () {
                    location.href="/admin.html";
                })
            }
        }
    })
</script>
</html>